load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "server",
    srcs = [
        "conn.go",
        "conn_stmt.go",
        "conn_stmt_params.go",
        "driver.go",
        "driver_tidb.go",
        "extension.go",
        "extract.go",
        "http_handler.go",
        "http_status.go",
        "mock_conn.go",
        "rpc_server.go",
        "server.go",
        "stat.go",
        "tokenlimiter.go",
    ],
    importpath = "github.com/pingcap/tidb/pkg/server",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/autoid_service",
        "//pkg/bindinfo",
        "//pkg/config",
        "//pkg/domain",
        "//pkg/domain/infosync",
        "//pkg/domain/resourcegroup",
        "//pkg/errno",
        "//pkg/executor",
        "//pkg/executor/mppcoordmanager",
        "//pkg/expression",
        "//pkg/extension",
        "//pkg/infoschema",
        "//pkg/kv",
        "//pkg/metrics",
        "//pkg/param",
        "//pkg/parser",
        "//pkg/parser/ast",
        "//pkg/parser/auth",
        "//pkg/parser/charset",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/parser/terror",
        "//pkg/planner/core",
        "//pkg/plugin",
        "//pkg/privilege",
        "//pkg/privilege/conn",
        "//pkg/privilege/privileges",
        "//pkg/privilege/privileges/ldap",
        "//pkg/server/err",
        "//pkg/server/handler",
        "//pkg/server/handler/extractorhandler",
        "//pkg/server/handler/optimizor",
        "//pkg/server/handler/tikvhandler",
        "//pkg/server/handler/ttlhandler",
        "//pkg/server/internal",
        "//pkg/server/internal/column",
        "//pkg/server/internal/dump",
        "//pkg/server/internal/handshake",
        "//pkg/server/internal/parse",
        "//pkg/server/internal/resultset",
        "//pkg/server/internal/util",
        "//pkg/server/metrics",
        "//pkg/session",
        "//pkg/session/txninfo",
        "//pkg/session/types",
        "//pkg/sessionctx",
        "//pkg/sessionctx/sessionstates",
        "//pkg/sessionctx/stmtctx",
        "//pkg/sessionctx/variable",
        "//pkg/sessiontxn",
        "//pkg/statistics/handle",
        "//pkg/store",
        "//pkg/store/driver/error",
        "//pkg/store/helper",
        "//pkg/tablecodec",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/arena",
        "//pkg/util/chunk",
        "//pkg/util/context",
        "//pkg/util/cpuprofile",
        "//pkg/util/dbterror",
        "//pkg/util/dbterror/exeerrors",
        "//pkg/util/execdetails",
        "//pkg/util/fastrand",
        "//pkg/util/hack",
        "//pkg/util/intest",
        "//pkg/util/logutil",
        "//pkg/util/memory",
        "//pkg/util/printer",
        "//pkg/util/resourcegrouptag",
        "//pkg/util/sqlexec",
        "//pkg/util/sqlkiller",
        "//pkg/util/sys/linux",
        "//pkg/util/timeutil",
        "//pkg/util/tls",
        "//pkg/util/topsql",
        "//pkg/util/topsql/state",
        "//pkg/util/topsql/stmtstats",
        "//pkg/util/tracing",
        "//pkg/util/versioninfo",
        "@com_github_blacktear23_go_proxyprotocol//:go-proxyprotocol",
        "@com_github_gorilla_mux//:mux",
        "@com_github_klauspost_compress//zstd",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_fn//:fn",
        "@com_github_pingcap_kvproto//pkg/autoid",
        "@com_github_pingcap_kvproto//pkg/coprocessor",
        "@com_github_pingcap_kvproto//pkg/diagnosticspb",
        "@com_github_pingcap_kvproto//pkg/mpp",
        "@com_github_pingcap_kvproto//pkg/tikvpb",
        "@com_github_pingcap_sysutil//:sysutil",
        "@com_github_prometheus_client_golang//prometheus",
        "@com_github_prometheus_client_golang//prometheus/promhttp",
        "@com_github_soheilhy_cmux//:cmux",
        "@com_github_stretchr_testify//require",
        "@com_github_tiancaiamao_appdash//traceapp",
        "@com_github_tikv_client_go_v2//tikvrpc",
        "@com_github_tikv_client_go_v2//util",
        "@com_sourcegraph_sourcegraph_appdash_data//:appdash-data",
        "@org_golang_google_grpc//:grpc",
        "@org_golang_google_grpc//channelz/service",
        "@org_golang_google_grpc//keepalive",
        "@org_golang_google_grpc//peer",
        "@org_uber_go_atomic//:atomic",
        "@org_uber_go_zap//:zap",
    ],
)

go_test(
    name = "server_test",
    timeout = "short",
    srcs = [
        "conn_stmt_params_test.go",
        "conn_stmt_test.go",
        "conn_test.go",
        "driver_tidb_test.go",
        "main_test.go",
        "mock_conn_test.go",
        "server_test.go",
        "stat_test.go",
        "tidb_library_test.go",
        "tidb_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":server"],
    flaky = True,
    shard_count = 50,
    deps = [
        "//pkg/config",
        "//pkg/domain",
        "//pkg/domain/infosync",
        "//pkg/expression",
        "//pkg/extension",
        "//pkg/keyspace",
        "//pkg/kv",
        "//pkg/metrics",
        "//pkg/param",
        "//pkg/parser/ast",
        "//pkg/parser/auth",
        "//pkg/parser/charset",
        "//pkg/parser/model",
        "//pkg/parser/mysql",
        "//pkg/parser/terror",
        "//pkg/server/internal",
        "//pkg/server/internal/column",
        "//pkg/server/internal/handshake",
        "//pkg/server/internal/parse",
        "//pkg/server/internal/testutil",
        "//pkg/server/internal/util",
        "//pkg/session",
        "//pkg/sessionctx/variable",
        "//pkg/sessiontxn",
        "//pkg/store/mockstore",
        "//pkg/store/mockstore/unistore",
        "//pkg/testkit",
        "//pkg/testkit/external",
        "//pkg/testkit/testdata",
        "//pkg/testkit/testmain",
        "//pkg/testkit/testsetup",
        "//pkg/types",
        "//pkg/util",
        "//pkg/util/arena",
        "//pkg/util/chunk",
        "//pkg/util/context",
        "//pkg/util/dbterror/exeerrors",
        "//pkg/util/replayer",
        "//pkg/util/sqlkiller",
        "//pkg/util/syncutil",
        "//pkg/util/topsql/state",
        "@com_github_docker_go_units//:go-units",
        "@com_github_pingcap_errors//:errors",
        "@com_github_pingcap_failpoint//:failpoint",
        "@com_github_pingcap_kvproto//pkg/metapb",
        "@com_github_stretchr_testify//require",
        "@com_github_tikv_client_go_v2//error",
        "@com_github_tikv_client_go_v2//testutils",
        "@com_github_tikv_client_go_v2//tikv",
        "@org_uber_go_goleak//:goleak",
    ],
)
